import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@WebServlet("/hello")//注解
public class HelloServlet extends HttpServlet {
    @Override//重写Doget方法，处理Http的GET请求
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("hello world");//只是显示在Tomcat显示台上
        resp.getWriter().write("hello world");//把字符串作为http响应的body部分，被浏览器显示到页面上
    }
}
